extends ../layout

block content
  style
    include index.css
  h1= title
  div= path
  form(action=(!!detail ? "/task/save" : "/task/add") method="post")
    if !!source
      input(type="hidden" name="source" value=source)
    if !!detail
      input(type="hidden" name="id" value=detail.id)
    if !!projectList
      div(style="margin-bottom: 10px;")
        label(for="project") 项目：
        select(name="project")
          option(value="" disabled selected=!(!!detail && !!detail.pro_id))
          each project in projectList
            option(value=project.id selected=(!!detail && project.id==detail.pro_id))= project.name
    if !!tasktypeList
      div(style="margin-bottom: 10px;")
        label(for="type") 类型：
        select(name="type")
          option(value="" disabled selected=!(!!detail && !!detail.type))
          each tasktype in tasktypeList
            option(value=tasktype.id selected=(!!detail && tasktype.id==detail.type))= tasktype.name
    div(style="margin-bottom: 10px;")
      label(for="con" style="display: inline-block; vertical-align: top;") 内容：
      textarea(type="text" name="con" cols="30" rows="5")= !!detail ? detail.con : ''
    if !!source && source == "fill"
      div(style="margin-bottom: 10px;")
        label(for="createtime") 日期：
        input(type="date" name="createtime" value=(!!detail ? detail.createtime : ""))  
    div(style="margin-bottom: 10px;")
      label(for="duration") 用时(小时)：
      input(type="number" step="0.1" name="duration" value=(!!detail ? detail.duration : 0))
    div(style="margin-bottom: 10px;")
      label(for="percent") 完成度：
      input(type="number" step="1" name="percent" value=(!!detail ? detail.percent : 0))
    div(style="margin-bottom: 10px;")
      input(type="submit" style="margin-left: 10px;" value=(!!detail ? "保存" : "添加"))
    if err
      div
        p.red= err
  script
    include index.js